// pages/flea/mySend/index.js
var app = getApp(), fetchApi = require("../../../utils/httpPost.js"), common_Js = require("../../../component/common.js")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    groupList:[],
    pageIndex:1,
    pageSize:10,
    loading: false,
    netWork: true,
    isLoading: true,
    netWork:false,
    hasData:false,
    estateId:0,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log('notice',options)
    if (options != undefined && options.q) {
      var q = decodeURIComponent(options.q) // 获取到二维码原始链接内容
      q = "?" + q.split("?")[1];
      this.data.query = q;
      console.log('q', q)
      options = common_Js.getQueryVariable(q);
    }

    if(options.eId){
      this.data.estateId = parseInt(options.eId)
    }else{
      console.log('app.getStorageSync("estate_id")', app.getStorageSync("estate_id"))
      this.data.estateId = app.getStorageSync("estate_id");
    }
    this.onHttpInit()
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },
  /**
   * 获取页面数据的 http请求
   */
  onHttpInit: function () {
    var that = this
    fetchApi.httpPost('/notice/group/list', {
      estateId:that.data.estateId,
    }, function (res) {
      if (res.data.code == 0) {
        that.setData({
          hasData: true,
          groupList: res.data.data.groupList
        })
      }
      that.setData({
         isLoading: false, loading: true, netWork: true,
      })
    }, function (res) {
        that.setData({ hasData: false,  isLoading: false,  loading: true, netWork: true })
    })
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新
  },
  noticeDetail(e){
    var item  = e.currentTarget.dataset.item;
    console.log('item', item)
    wx.navigateTo({
      url: '/pages/notice/list/index?eId='+ this.data.estateId + '&gId=' + item.id+'&name=' + item.groupName,
    })
  },
})